L5 23 L Variable Shadowing V3
Variable Shadowing
Without pasting into your console, what do you think this code will print out?
var x = 1; function addTwo() { x = x + 2; } addTwo(); x = x + 1; console.log(x);
1
2
3
4
Shadowing 2
var x = 1; function addTwo() { var x = x + 2; } addTwo(); x = x + 1; console.log(x);
Next Concept